package com.example.fashionshoes.config;

import lombok.Data;
import org.springframework.amqp.core.*;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(prefix = "rabbitmq-config")
@Data
public class RabbitMQConfig {
    private String normalExchangeName;
    private String queueName;
    @Bean
    public DirectExchange normalDirectExchange(){
        return ExchangeBuilder.directExchange(normalExchangeName).build();
    }
    @Bean
    public Queue queue(){
        return QueueBuilder.durable(queueName).build();
    }
    @Bean
    public Binding binding(DirectExchange normalDirectExchange,Queue queue){
        return BindingBuilder.bind(queue).to(normalDirectExchange).with("order");
    }
}
